class CQueue
{
public:
    stack<int> a, b;
    CQueue() {}

    void appendTail(int value)
    {
        a.push(value);
    }

    int deleteHead()
    {
        if (!b.empty())
        {
            int s1 = b.top();
            b.pop();
            return s1;
        }

        if (a.empty()) return -1;

        while (!a.empty())
        {
            b.push(a.top());
            a.pop();
        }
        int s2 = b.top();
        b.pop();
        return s2;
    }
};